package top.boking.dao;

import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;
import top.boking.domain.Student;

import java.util.List;

public interface StudentDao {

    @Select("select *from student")
    @Results(id="stumap",value = {@Result(id=true,column = "id",property = "id"),
            @Result(column = "stuname",property = "name"),
            @Result(column = "cid",property = "cid"),
            @Result(property = "clas",column = "cid",one=@One(select="top.boking.dao.ClaDao.findByid",fetchType= FetchType.EAGER))
    }
    )
    List<Student> findAll();

    @Select("select *from student where cid=#{integer}")
    @Results(id="stu",value = {
            @Result(id=true,column = "id",property = "id"),
            @Result(column = "stuname",property = "name"),
            @Result(column = "cid",property = "cid"),
            @Result(property = "clas",column = "cid",one =@One(select="top.boking.dao.ClaDao.findByid",fetchType = FetchType.EAGER))
    }
    )
    List<Student> findByid(Integer integer);


}
